\(\int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx\) [22]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 24, antiderivative size = 27 \[ \int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {i (a+i a \tan (c+d x))^3}{3 a d} \]

[Out]

-1/3*I*(a+I*a*tan(d*x+c))^3/a/d

Rubi [A] (verified)

Time = 0.05 (sec) , antiderivative size = 27, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.083, Rules used = {3568, 32} \[ \int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {i (a+i a \tan (c+d x))^3}{3 a d} \]

[In]

Int[Sec[c + d*x]^2*(a + I*a*Tan[c + d*x])^2,x]

[Out]

((-1/3*I)*(a + I*a*Tan[c + d*x])^3)/(a*d)

Rule 32

Int[((a_.) + (b_.)*(x_))^(m_), x_Symbol] :> Simp[(a + b*x)^(m + 1)/(b*(m + 1)), x] /; FreeQ[{a, b, m}, x] && N
eQ[m, -1]

Rule 3568

Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Dist[1/(a^(m - 2)*b
*f), Subst[Int[(a - x)^(m/2 - 1)*(a + x)^(n + m/2 - 1), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x
] && EqQ[a^2 + b^2, 0] && IntegerQ[m/2]

Rubi steps \begin{align*} \text {integral}& = -\frac {i \text {Subst}\left (\int (a+x)^2 \, dx,x,i a \tan (c+d x)\right )}{a d} \\ & = -\frac {i (a+i a \tan (c+d x))^3}{3 a d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.09 (sec) , antiderivative size = 50, normalized size of antiderivative = 1.85 \[ \int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {a^2 \tan (c+d x)}{d}+\frac {i a^2 \tan ^2(c+d x)}{d}-\frac {a^2 \tan ^3(c+d x)}{3 d} \]

[In]

Integrate[Sec[c + d*x]^2*(a + I*a*Tan[c + d*x])^2,x]

[Out]

(a^2*Tan[c + d*x])/d + (I*a^2*Tan[c + d*x]^2)/d - (a^2*Tan[c + d*x]^3)/(3*d)

Maple [A] (verified)

Time = 1.97 (sec) , antiderivative size = 47, normalized size of antiderivative = 1.74

method result size
risch \(\frac {8 i a^{2} \left (3 \,{\mathrm e}^{4 i \left (d x +c \right )}+3 \,{\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}\) \(47\)
derivativedivides \(\frac {-\frac {a^{2} \left (\sin ^{3}\left (d x +c \right )\right )}{3 \cos \left (d x +c \right )^{3}}+\frac {i a^{2}}{\cos \left (d x +c \right )^{2}}+a^{2} \tan \left (d x +c \right )}{d}\) \(51\)
default \(\frac {-\frac {a^{2} \left (\sin ^{3}\left (d x +c \right )\right )}{3 \cos \left (d x +c \right )^{3}}+\frac {i a^{2}}{\cos \left (d x +c \right )^{2}}+a^{2} \tan \left (d x +c \right )}{d}\) \(51\)

[In]

int(sec(d*x+c)^2*(a+I*a*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

8/3*I*a^2*(3*exp(4*I*(d*x+c))+3*exp(2*I*(d*x+c))+1)/d/(exp(2*I*(d*x+c))+1)^3

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 75 vs. \(2 (21) = 42\).

Time = 0.23 (sec) , antiderivative size = 75, normalized size of antiderivative = 2.78 \[ \int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {8 \, {\left (-3 i \, a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} - 3 i \, a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} - i \, a^{2}\right )}}{3 \, {\left (d e^{\left (6 i \, d x + 6 i \, c\right )} + 3 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \]

[In]

integrate(sec(d*x+c)^2*(a+I*a*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-8/3*(-3*I*a^2*e^(4*I*d*x + 4*I*c) - 3*I*a^2*e^(2*I*d*x + 2*I*c) - I*a^2)/(d*e^(6*I*d*x + 6*I*c) + 3*d*e^(4*I*
d*x + 4*I*c) + 3*d*e^(2*I*d*x + 2*I*c) + d)

Sympy [F]

\[ \int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx=- a^{2} \left (\int \tan ^{2}{\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}\, dx + \int \left (- 2 i \tan {\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}\right )\, dx + \int \left (- \sec ^{2}{\left (c + d x \right )}\right )\, dx\right ) \]

[In]

integrate(sec(d*x+c)**2*(a+I*a*tan(d*x+c))**2,x)

[Out]

-a**2*(Integral(tan(c + d*x)**2*sec(c + d*x)**2, x) + Integral(-2*I*tan(c + d*x)*sec(c + d*x)**2, x) + Integra
l(-sec(c + d*x)**2, x))

Maxima [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 21, normalized size of antiderivative = 0.78 \[ \int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {i \, {\left (i \, a \tan \left (d x + c\right ) + a\right )}^{3}}{3 \, a d} \]

[In]

integrate(sec(d*x+c)^2*(a+I*a*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

-1/3*I*(I*a*tan(d*x + c) + a)^3/(a*d)

Giac [A] (verification not implemented)

none

Time = 0.46 (sec) , antiderivative size = 42, normalized size of antiderivative = 1.56 \[ \int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {a^{2} \tan \left (d x + c\right )^{3} - 3 i \, a^{2} \tan \left (d x + c\right )^{2} - 3 \, a^{2} \tan \left (d x + c\right )}{3 \, d} \]

[In]

integrate(sec(d*x+c)^2*(a+I*a*tan(d*x+c))^2,x, algorithm="giac")

[Out]

-1/3*(a^2*tan(d*x + c)^3 - 3*I*a^2*tan(d*x + c)^2 - 3*a^2*tan(d*x + c))/d

Mupad [B] (verification not implemented)

Time = 4.06 (sec) , antiderivative size = 35, normalized size of antiderivative = 1.30 \[ \int \sec ^2(c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {a^2\,\mathrm {tan}\left (c+d\,x\right )\,\left (-{\mathrm {tan}\left (c+d\,x\right )}^2+\mathrm {tan}\left (c+d\,x\right )\,3{}\mathrm {i}+3\right )}{3\,d} \]

[In]

int((a + a*tan(c + d*x)*1i)^2/cos(c + d*x)^2,x)

[Out]

(a^2*tan(c + d*x)*(tan(c + d*x)*3i - tan(c + d*x)^2 + 3))/(3*d)